import requests
import json

url = "https://search.51rc.com/job/"
# 代理
# proxies={
#    'http':'http://127.0.0.1:8080',
#    'https':'http://127.0.0.1:8080'
# }

post_name = input("输入岗位名称：")
data = {"OrderBy": 0, "jobTypeId": "", "majorTypeId": "", "regionId": "3217", "industryId": "", "mapPlaceId": 0,
        "minSalary": 0, "maxSalary": 0, "minSalaryvalue": "", "maxSalaryvalue": "", "experienceId": 0, "replyRate": 0,
        "autoReplyDay": 0, "isNegotiable": False, "educationId": "", "employType": 0, "keyWord": post_name, "Page": 1,
        "companySizeId": 0, "welfare": "", "isOnline": False, "distance": 0, "onlyEnv": False, "selectRegionId": "32",
        "filterWelfare": [], "filterJobType": None, "filterRegion": {"id": "3217", "value": "临沂市"},
        "filterEducation": None, "filterSalary": {}, "filterExperience": None, "filterEmployType": None,
        "filterCompanySize": None, "filterReplyRate": None, "serverNo": "4", "city": {"id": "3217", "value": "临沂市"},
        "district": {"id": "", "value": ""}, "place": {"id": "", "value": ""}, "firstJob": {"id": "", "value": ""},
        "secondJob": {"id": "", "value": ""}, "regionType": 2, "jobType": 1, "showWords": post_name}

# 设置Content-Type值为application/json
# headers = {'Content-Type': 'application/json'}
# 用json.dumps把data格式化成json
# res = requests.post(url=url, headers=headers, data=json.dumps(data), proxies=proxies)

# 也可以使用
res = requests.post(url=url, json=data)

jobList = res.json()["jobList"]
# print(jobList)

for item in jobList:
    item_ = {"岗位名称：": item["jobName"],
             "公司名称：": item["companyName"],
             "薪资待遇：": item["salary"],
             "福利待遇：": item["welfare"],
             # "招聘人数：": item["totalCount"],
             "工作地点：": item["city"] + item["address"],
             "最近刷新：": item["refreshDate"]
             }
    print(item_)
